import { View } from "@tarojs/components";
import { useState } from "react";
import Taro from "@tarojs/taro";
import { AtButton, AtInput, AtTabsPane } from "taro-ui";
import "./certification.scss";

const Certification = () => {
  // 标签页将认证页面分成两个模块6
  // const tabList = [{ title: '个人认证' }] { title: '企业认证' }]
  const [current] = useState(0);
  const [realName, setName] = useState("");
  const [identityId, setIdentifyID] = useState("");
  const [phone, setPhone] = useState("");

  // const handleClick = value => {
  //   setCurrent(value);
  // };
  // const [state, setState] = useState({ value: "" });
  // const value=state;
  // const handleChange = value => {
  //   () => {
  //     setState(value);
  //   };
  //   return "value";
  // };
  const Save = () => {
    const obj = {
      realName,
      phone,
      identityId
    };
    try {
      Taro.cloud
        .callFunction({
          name: "logins",
          data: {
            $url: "addReal",
            data: obj
          }
        })
        .then(() => {});
    } catch (err) {
      console.log(err);
    }
  };

  return (
    <View className="index">
      {/* 标签页将认证页面分成两个模块 */}
      {/*<AtTabs current={current} tabList={tabList} onClick={handleClick}>*/}
      {/* 个人认证 */}
      <AtTabsPane current={current} index={0}>
        <View className="personId">
          <AtInput
            name="value"
            title="姓名"
            placeholder="请输入您的姓名"
            value={realName}
            onChange={(res: any) => setName(res)}
          />
          <AtInput
            name="value"
            title="身份证号"
            type="phone"
            placeholder="请输入您的身份证号"
            value={identityId}
            onChange={(res: any) => setIdentifyID(res)}
          />
          <AtInput
            name="value"
            title="手机号"
            placeholder="请输入您的手机号"
            value={phone}
            onChange={(res: any) => setPhone(res)}
          />
          {/*<AtInput*/}
          {/*  name='value'*/}
          {/*  title='验证码'*/}
          {/*  placeholder='请输入验证码'*/}
          {/*  value={state.value}*/}
          {/*  onChange={handleChange}*/}
          {/*>*/}
          {/*    <View >发送验证码</View>*/}
          {/*</AtInput>*/}
          <AtButton className="preservation" onClick={Save}>
            保存
          </AtButton>
          {/* <FormTextInput
                label="姓名"
                fieldProps={{
                name: "name",
                placeholder: "请输入您的姓名"
                }}
                rules={{ required: true, message: "姓名不能为空" }}
                />
                <FormTextInput
                label="身份证号"
                fieldProps={{
                name: "idName",
                placeholder: "请输入您的身份证号"
                }}
                rules={{ required: true, message: "身份证号不能为空" }}
                />
                <FormTextInput
                label="手机号"
                fieldProps={{
                name: "number",
                placeholder: "请输入您的手机号"
                }}
                rules={{ required: true, message: "手机号不能为空" }}
                /> */}
        </View>
      </AtTabsPane>
      {/* 企业认证 */}
      {/*    <AtTabsPane current={current} index={1}>*/}
      {/*        /!* 企业认证 *!/*/}
      {/*    <View className='companyId'>*/}
      {/*    <AtInput*/}
      {/*      name='value'*/}
      {/*      title='企业名称'*/}
      {/*      placeholder='请输入您所属的企业名称'*/}
      {/*      value={state.value}*/}
      {/*      onChange={handleChange}*/}
      {/*    />*/}
      {/*        <AtInput*/}
      {/*          name='value'*/}
      {/*          title='营业执照号'*/}
      {/*          placeholder='请输营业执照号'*/}
      {/*          value={state.value}*/}
      {/*          onChange={handleChange}*/}
      {/*        />*/}
      {/*        <AtInput*/}
      {/*          name='value'*/}
      {/*          title='法人姓名'*/}
      {/*          placeholder='请输入法人姓名'*/}
      {/*          value={state.value}*/}
      {/*          onChange={handleChange}*/}
      {/*        />*/}
      {/*        <AtInput*/}
      {/*          name='value'*/}
      {/*          title='手机号'*/}
      {/*          maxlength={11}*/}
      {/*          placeholder='请输入您的手机号'*/}
      {/*          value={state.value}*/}
      {/*          onChange={handleChange}*/}
      {/*        />*/}
      {/*        <AtInput*/}
      {/*          name='value'*/}
      {/*          title='验证码'*/}
      {/*          placeholder='请输入验证码'*/}
      {/*          value={state.value}*/}
      {/*          onChange={handleChange}*/}
      {/*        >*/}
      {/*            <View >发送验证码</View>*/}
      {/*        </AtInput>*/}
      {/*        <AtButton className='preservation' onClick={Save}>保存</AtButton>*/}
      {/*    </View>*/}
      {/*    </AtTabsPane>*/}
    </View>
  );
};

export default Certification;
